/* sdcard/sdcard_config.h
 *
 * SD/MMC/SDHC driver
 *
 * Copyright (c) 2006-2011 by Roland Riegel
 * Author: Roland Riegel
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2 or 2.1
 * of the License.
 */

#ifndef __SDCARD_CONFIG_H__
#define __SDCARD_CONFIG_H__

#include <stdint.h>

/**
 * Controls allocation of memory.
 *
 * Set to 1 to use malloc()/free() for allocation of structures
 * like file and directory handles,
 * Set to 0 to use pre-allocated fixed-size handle arrays.
 */
#define USE_DYNAMIC_MEMORY 		0

/**
 * Controls MMC/SD write support.
 *
 * Set to 1 to enable MMC/SD write support, set to 0 to disable it.
 */
#define SD_RAW_WRITE_SUPPORT 	1

/**
 * Controls MMC/SD write buffering.
 *
 * Set to 1 to buffer write accesses, set to 0 to disable it.
 *
 * Note: This option has no effect when SD_RAW_WRITE_SUPPORT is 0.
 */
#define SD_RAW_WRITE_BUFFERING 	1

/**
 * Controls MMC/SD access buffering.
 *
 * Set to 1 to save static RAM, but be aware that you will
 * lose performance.
 *
 * Note: When SD_RAW_WRITE_SUPPORT is 1, SD_RAW_SAVE_RAM will
 *       be reset to 0.
 */
#define SD_RAW_SAVE_RAM 		1

/**
 * Controls support for SDHC cards.
 *
 * Set to 1 to support so-called SDHC memory cards, i.e. SD
 * cards with more than 2 gigabytes of memory.
 */
#define SD_RAW_SDHC 			0


#define sd_configure_pin_available() 	DDRD &= ~(1 << DDD3)
#define sd_configure_pin_locked() 		DDRD &= ~(1 << DDD3)

#define sd_get_pin_available() 			(PIND & (1 << PIND3))
#define sd_get_pin_locked() 			(PIND & (1 << PIND3))

#if SD_RAW_SDHC
    typedef uint64_t offset_t;
#else
    typedef uint32_t offset_t;
#endif

/* configuration checks */
#if 	SD_RAW_WRITE_SUPPORT
#undef 	SD_RAW_SAVE_RAM
#define SD_RAW_SAVE_RAM 0
#else
#undef 	SD_RAW_WRITE_BUFFERING
#define SD_RAW_WRITE_BUFFERING 0
#endif


#endif // __SDCARD_CONFIG_H__
